<?php

/**
 * @fileoverview
 * 用户的model。
 *
 */

class User extends AppModel {

	var $name = 'User';

	var $validate = array(
		'email' => array(
			'email'		=> array('rule' => 'email'),
			'required'	=> VALID_NOT_EMPTY,
		),
		'blogname' => array(
			'required'	=> VALID_NOT_EMPTY,
		),
		'blogurl' => array(
			'url'		=> array('rule' => 'url'),
			'required'	=> VALID_NOT_EMPTY,
		),
		'description' => array(
			'required'	=> VALID_NOT_EMPTY,
		),
	);

	/**
	 * 用户登录认证
	 * @param {String} $email 用户输入的电子邮件
	 * @param {String} $password 用户输入的密码
	 * @type Array
	 * @return 认证成功则返回当前用户的信息，否则返回FALSE
	 */
	function auth($email, $password) {

		$user = $this->find("email='$email' AND password=MD5('$password')");
		if ($user) {
			return $user;
		} else {
			return FALSE;
		}
	}

}

?>
